<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <title>Vector-Search</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            margin: 20px;
        }
        h1, h3, h3, h4, h5 {
            color: #333;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 12px;
            text-align: left;
        }
        th {
            background-color: #f4f4f4;
        }
        code {
            background-color: #f4f4f4;
            padding: 2px 4px;
            border-radius: 4px;
            font-family: Consolas, "Courier New", monospace;
        }
        #codeBlock {
            display: none;
            margin-top: 10px;
        }
        #toggleButton {
            background-color: #007bff;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
        }
        #toggleButton:hover {
            background-color: #0056b3;
        }
        .round-button {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border: none;
            background-color: #007bff; 
            color: white;
            font-size: 18px;
            font-weight: bold;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: background-color 0.3s;
        }

        .round-button:hover {
            background-color: #0056b3;
            opacity: 0.5;
        }   
    </style>
</head>
<body>
<h1 style="text-align: center;"> Vector-Search Usage <iframe src="https://ghbtns.com/github-btn.html?user=sssxyd&repo=dict-vector-search&type=star&size=large&text=false" frameborder="0" scrolling="0" width="40" height="30" title="GitHub"></iframe></h1>

<h2>1. 上传字典 </h2>
<div id="api1">
    <h3>通过HTTP接口上传字典文件</h3>
    <h3>或者Copy字典文件到 /path/to/vector-search/dict 目录并命名为dict_words.csv</h3>
    <pre><code>
        POST /put HTTP/1.1
        Content-Type: form-data
        {
            "file": "xxxx.csv",
        }
    </code></pre>

    <h3>字典文件(dict_words.csv)格式</h3>
    <pre><code>
        1, 奥利司他胶囊
        code2, 布洛芬缓释片
    </code></pre>
</div>

<h2>2. 创建索引 </h2>
<div id="api2">
    <pre><code>
        cd /path/to/vector-search
        ./vector-search -h  # 查看帮助
        ./vector-search index -min=2 -max=4 -batch=200 -worker=4 # 创建索引
    </code></pre>
</div>

<h2>3. 启动/重启服务 </h2>

<h2>4. 查看服务详情 </h2>
<div id="api4">
    <pre><code>
        GET /info HTTP/1.1
    </code></pre>
</div>

<h2>5. 向量搜索</h2>
<div id="api5">
    <pre><code>
        GET /search?word=氯已定&top=1&pinyin=1 HTTP/1.1
    </code></pre>
    <h3>Response</h3>
    <pre><code>
{
  "code": 1,                            # 1: success, others: error
  "message": "success",
  "result": [
    {
      "index": "WORD",                  # 词索引
      "code": "3277",
      "word": "利多卡因氯己定气雾剂",
      "score": 4,                       # 匹配分数
      "distance": 0.199912115931511     # 向量距离
    }
  ],
  "micro": 108711                       # 耗时-微秒
}
    </code></pre>
</div>

</body>
</html>
